<template>
	<view>
		<view class="inputs_info">
			<view class="ipt">
				<input v-model="params.companyName" @confirm='inputs' confirm-type="search" class="inputs" type="text" placeholder="大家都在搜" />
				<uni-icons type="search" size="24" color="#888888"></uni-icons>
			</view>
		</view>
		<view class="tit page_width">
			<view class="cont_flex " v-for="(item,index) in searchList" :key="index" @click="goPage(item)">
				<view class="flex_l">
					<image :src="item.companyHead" mode=""></image>
				</view>
				<view class="flex_r">
					<view class="ts1">{{item.companyName}}</view>
					<view class="ts2">主营：{{item.companyBusiness}}</view>
					<view class="ts2">电话：<span style="color: red;">{{item.companyPhone}}</span></view>
					<view class="ts2">地址：{{item.companyAddress}}</view>
				</view>
			</view>
		</view>
		<uni-load-more v-if="!searchList.length <= 0" :status="statusshow"></uni-load-more>
		<kong v-if="searchList.length == 0"></kong>
	</view>
</template>

<script>
	import { getCompanys} from '@/common/http.api.js';
	export default {
		data() {
			return {
				params:{
					pageNum: 1,
					pageSize: 10,
					companyName:''
				},
				searchList:[],
				statusshow:'loading'
			};
		},
		onLoad(e) {
			this.params.companyName = e.textinfo
			this.getList()
		},
		methods:{
			inputs(e){
				this.searchList = []
				this.params = {
					pageNum: 1,
					pageSize: 5,
					companyName:e.detail.value
				}
				getCompanys(this.params).then(res=>{
					this.searchList.push(...res.rows)
				})
			},
			getList(){
				getCompanys(this.params).then(res=>{
					this.searchList.push(...res.rows)
					if(this.searchList.length == res.total){
						this.statusshow = 'no-more'
					}
				})
			},
			onReachBottom(){
				this.params.pageNum ++ 
				this.getList()
			},
			goPage(item){
				uni.navigateTo({
					url:`/pages/business/busInfo?id=${item.id}`
				})
			}
		}
	}
</script>

<style lang="less">
	page {
		background-color: #F0F0F1;
	}

	.tit {
		width: 716rpx;
		margin: 20rpx auto;
		.cont_flex {
			background-color: #fff;
			border-radius: 20rpx;
			padding: 24rpx 14rpx;
			box-sizing: border-box;
			display: flex;
			margin-bottom: 20rpx;
		
			.flex_l {
				width: 200rpx;
				height: 200rpx;
				image {
					width: 200rpx;
					height: 200rpx;
				}
			}

			.flex_r {
				display: flex;
				flex-direction: column;
				justify-content: space-around;
				margin-left: 10rpx;
				flex: 1;
				.ts1 {
					color: #101010;
					font-size: 32rpx;
					font-weight: bold;
				}

				.ts2 {
					color: #666666;
					font-size: 24rpx;
					width: 450rpx;
					white-space:nowrap;
					overflow:hidden;
					text-overflow:ellipsis;
				}
			}

		}
	}
</style>